package com.travel.model.entity.auth;

import com.travel.model.enums.Role;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.*;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

@Data
@Entity
@Table(name = "users")
@EntityListeners(AuditingEntityListener.class)
@Schema(description = "用户实体")
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Schema(description = "用户ID")
    private Long id;

    @Schema(description = "用户名")
    @Column(unique = true)
    private String username;

    @Schema(description = "密码")
    @Column(nullable = false)
    private String password;

    @Schema(description = "邮箱")
    @Column(unique = true)
    private String email;

    @Schema(description = "昵称")
    private String nickname;

    @Schema(description = "头像")
    private String avatar;

    @Schema(description = "手机号")
    private String phone;

    @Schema(description = "用户角色")
    @Enumerated(EnumType.STRING)
    private Role role;

    @Schema(description = "用户状态")
    private Integer status;

    @CreatedDate
    @Schema(description = "创建时间")
    private LocalDateTime createdTime;

    @LastModifiedDate
    @Schema(description = "更新时间")
    private LocalDateTime updatedTime;
} 